<template>
  <div class="home">
    <el-row justify="center">
      <el-col :span="8">
        <img
          class="centent_img"
          src="@/assets/img/callout.10de9efe.svg"
          alt="callout"
        />
        <p class="centent_text">随心写作，自由表达</p>
        <el-button type="primary" @click="addArtice">开始写文章</el-button>
      </el-col>
    </el-row>
    <h3 class="centent_title">发现精彩</h3>
    <div class="content">
      <el-row :gutter="20">
        <el-col :span="8" v-for="item in dataList" :key="item._id">
          <el-card>
            <img
              :src="item.avatar.url"
              class="image"
              style="width: 50px; height: 50px; border-radius: 50%"
              alt=""
            />
            <div>
              <div class="title">{{ item.title }}</div>
              <div class="description">
                {{ item.description }}
              </div>
              <div class="btn">
                <el-button type="primary" plain>进入专栏</el-button>
              </div>
            </div>
          </el-card>
        </el-col>
      </el-row>
    </div>
  </div>
</template>

<script lang="ts" setup>
import { useRouter } from "vue-router";
import { useStore } from "vuex";
import { ref, reactive, toRefs } from "vue";
import { getColumnList } from "@/utis/api";
const router = useRouter();
const store = useStore();

const porss = {
  pageSize: 5,
  currentPage: 1,
};
const dataList = ref([]);
const data = reactive({});
getColumnList(porss).then((res) => {
  // console.log("42", res);
  dataList.value = res.data.list;
  console.log(dataList);
});
const addArtice = () => {
  router.push("/addArticle");
};
</script>

<style lang="scss" scoped>
.home {
  margin: 60px 0;
  .centent_img {
    width: 222px;
    height: auto;
  }
  .centent_text {
    text-align: center;
    margin: 20px 0;
  }
  .centent_title {
    margin: 20px 0;
    font-size: 30px;
  }
}
.content {
  display: flex;
  justify-content: center;
  align-items: center;
  .title {
    padding: 14px;
    font-size: 20px;
  }
  .description {
    font-size: 18px;
    color: #6c757d;
    text-align: left;
    text-indent: 2em;
    width: 100%;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    text-overflow: ellipsis;
    -webkit-box-orient: vertical;
    line-height: 20px;
    min-height: 40px;
  }
  .btn {
    margin: 50px 0;
  }
}
</style>
